package com.yanqu.road.server.cmd.activity.doublespring.cross;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.DoubleSpringProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.doublespring.DoubleSpringActivityModule;
import com.yanqu.road.server.manger.activity.doublespring.DoubleSpringActivityMgr;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_DOUBLE_SPRING_SYNC_SCORE_FROM_CROSS,desc = "踏春游记-跨服返回-同步更新积分")
public class DoubleSpringSyncScoreFromCrossCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        DoubleSpringProto.DoubleSpringUserDataTwoSyncMsg reqMsg = DoubleSpringProto.DoubleSpringUserDataTwoSyncMsg.parseFrom(packet.getBytes());
        if (player != null) {
            //更新下condition
            player.getModule(DoubleSpringActivityModule.class).updateTravelScore(reqMsg.getActivityId(), reqMsg.getUserData().getScoreData().getTotalScore());
            //同步
            player.sendPacket(Protocol.U_DOUBLE_SPRING_USER_DATA_TWO_SYNC, reqMsg.toBuilder());
        }
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
